var panel1 = angular.module('panel1', ['emailParser']).controller('panel1Ctrl', ['$scope', 'EmailParser',function($scope,$timeout,EmailParser){
	$scope.dataType =  [
	{name:"By Step Instruction"},
	{name:"By Agile Doc Number"},
	{name:"By Agile Part Number"},
	{name:"By Agile Deviation Number"},
	{name:"By Agile Deviation Date"},
	{name:"By Local Document"},
	{name:"By Local Deviation Number"},    
	{name:"Engineering Notes by Route Independent"},
	{name:"By Engineering Notes"},
	{name:"By URL"},
	{name:"By URL"},
	{name:"By URL"},
	{name:"By URL"},
	{name:"By URL"},
	{name:"By URL"},
	{name:"By URL"},
	{name:"By URL"},
	{name:"By URL"}
	];
	$scope.selected = $scope.dataType[0].name;
	$scope.names = [
        {name:'Jani',country:'Norway'},
        {name:'Hege',country:'Sweden'},
        {name:'Kai',country:'Denmark'}
    ];
    $scope.to = 'ari@fullstack.io';
    $scope.emailBody = 'Hello __to__';
    $scope.$watch('emailBody', function(body) {
    	 if (body) {
                $scope.previewText =
                  EmailParser.parsew(body, {
                    to: $scope.to
                  });
              }
    });

}]);

/**
* emailParser Module
*
* Description
*/
angular.module('emailParser', []).
config(['$interpolateProvider',function($interpolateProvider) {
	$interpolateProvider.startSymbol('__');
	$interpolateProvider.endSymbol('__');
}]).
factory('EmailParser', ['$interpolate',function($interpolate) {
	return {
		parsew: function(text, context) {
			var template = $interpolate(text);
			return template(context);
		}
	};
}]);

!function(){
	var Class = function(){
		var klass = function(){
			this.init.apply(this,arguments);
		}
		klass.prototype.init = function(){
		}
		return klass;
	};

	var Person = new Class();

	Person.fn = Person.prototype;
	Person.fn.init = function(){
		
	};

	Person.find = function(id){
		switch(id){
			case 1: 
				//alert(id);
				break;
			case 2:
				alert(id);
				break;
			default: 
				alert('id not right!');
				break;
		}
	}

	var person = new Person();
	Person.find(2);

}(jQuery);
